﻿using System.Configuration;

namespace Builderator.Core.Database
{
    public class DatabaseInfo : ConfigurationSection
    {
        [ConfigurationProperty("Server", DefaultValue="localhost", IsRequired=true)]
        public string Server
        {
            get { return this["Server"] as string; }
            set { this["Server"] = value; }
        }

        [ConfigurationProperty("Instance", DefaultValue = "builderator", IsRequired = true)]
        public string Instance
        {
            get { return this["Instance"] as string; }
            set { this["Instance"] = value; }
        }

        [ConfigurationProperty("Database", DefaultValue = "builderator", IsRequired = true)]
        public string Database
        {
            get { return this["Database"] as string; }
            set { this["Database"] = value; }
        }

        [ConfigurationProperty("User", DefaultValue = "sa", IsRequired = true)]
        public string User
        {
            get { return this["User"] as string; }
            set { this["User"] = value; }
        }

        [ConfigurationProperty("Password", DefaultValue = "build!1234", IsRequired = true)]
        public string Password
        {
            get { return this["Password"] as string; }
            set { this["Password"] = value; }
        }

        public override string ToString()
        {
            return string.Format("Server={0}\\{1};Database={2};User ID={3};Password={4}", this.Server, this.Instance, this.Database, this.User, this.Password);
        }
    }
}